<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>
    <style type="text/css">
            body, html{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
            #allmap{height:500px;width:800px;}
            #r-result{width:100%; font-size:14px;}
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=xH9CkRR96Vk6KWM2KH5qhlsSncNgAGdQ"></script>
    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" role="form" action="{:U('update')}" method="post">
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 驾校名称 </label>
                                <div class="col-sm-9">
                                    <input type="text" disabled="disabled" class="rcol-xs-10 col-sm-5"
                                           value="{$member.name}">
                                    <span class="help-inline col-xs-12 col-sm-7">
                                                <span class="middle">无法修改</span>
                                            </span>
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 用户名 </label>
                                <div class="col-sm-9">
                                    <input type="text" disabled="disabled" class="rcol-xs-10 col-sm-5"
                                           value="{$member.user}">
                                    <span class="help-inline col-xs-12 col-sm-7">
                                                <span class="middle">无法修改</span>
                                            </span>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 用户密码 </label>
                                <div class="col-sm-9">
                                    <input type="password" name="password" id="password" placeholder="用户密码"
                                           class="col-xs-10 col-sm-5" value="">
                                    <span class="help-inline col-xs-12 col-sm-7">
                                                <span class="middle">留空不修改</span>
                                            </span>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 缩略图 </label>
                                <div class="col-sm-9">
                                    <div class="col-xs-10 col-sm-5">{:UpImage("head",100,100,$member['head'])}</div>
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">仅支持jpg、gif、png、bmp、jpeg，且小于1MB。</span>
											</span>
                                </div>

                            </div>
                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-6"> 电话号码 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="phone" id="phone" placeholder="电话号码"
                                           class="col-xs-10 col-sm-5" value="{$member['phone']}">
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2">
                                    简介内容 </label>
                                <div class="col-sm-9">
                                        <textarea name="content" id="content" style="width:100%;height:400px;visibility:hidden;">{$member['content']}</textarea>
                                </div>
                            </div>
                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-10">
                                    选择地区 </label>
                                <div class="col-sm-9">
                                    <select id="prov" name="prov" onchange="getCity('prov','city')" class="rcol-xs-5 col-sm-2" disabled="disabled">
                                       <option>-选择省-</option>
                                    </select>
                                    <select id="city" name="city" style="display: none;" onchange="getCity('city','dist')" disabled="disabled" class="rcol-xs-5 col-sm-2">
                                      <option>-选择市-</option>
                                    </select>
                                    <select id="dist" onchange="theLocation()" name="dist" style="display: none;" disabled="disabled" class="rcol-xs-5 col-sm-2">
                                       <option>-选择区域-</option>
                                    </select>
                                    <span class="help-inline col-xs-12 col-sm-7">
                                                <span class="middle">无法修改</span>
                                            </span>
                                </div>
                            </div>
                            
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 定位 </label>
                                <div class="col-sm-9">
                                    <input type="text" oninput ="theLocationCom()" name="com" id="com" class="rcol-xs-10 col-sm-5"
                                           value="{$member['com']}" placeholder="定位" disabled="disabled" />
                                    <span class="help-inline col-xs-12 col-sm-7">
                                                <span class="middle">无法修改</span>
                                            </span>
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 地址 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="address" disabled="disabled" id="address" placeholder="地址"
                                           class="col-xs-10 col-sm-5" value="{$member['address']}" />
                                    <span class="help-inline col-xs-12 col-sm-7">
                                                <span class="middle">无法修改</span>
                                            </span>
                                </div>
                            </div>
    
                            <div class="space-4"></div>
                            <div id="allmap"></div>
                            <div class="space-4"></div>
                            <input type="hidden" name="lng" id="lng" value="{$member['lng']}" >
                            <input type="hidden" name="lat" id="lat" value="{$member['lat']}" >

                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

</div><!-- /.main-container -->
<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script src="__PUBLIC__/qwadmin/js/date-time/bootstrap-datepicker.js"></script>
<script type="text/javascript">
    jQuery(function ($) {
        $('#birthday').datepicker({
            format: 'yyyy-mm-dd',
            weekStart: 1,
            autoclose: true,
            todayBtn: 'linked',
            language: 'cn'
        });
    });
    $(function () {
        $("#tabs").tabs();
        var editor = KindEditor.create('textarea[name="content"]', {
            uploadJson: '__PUBLIC__/kindeditor/php/upload_json.php',
            fileManagerJson: '__PUBLIC__/kindeditor/php/file_manager_json.php',
            allowFileManager: true,
            afterBlur: function () {
                this.sync();
            }
        });
    });
</script>
<script type="text/javascript">
var lng='';
var lat='';
//地图
var map = new BMap.Map("allmap");
        var point = new BMap.Point(113.631349,34.753488);
        map.centerAndZoom(point,11);
//地图缩放      
        map.enableScrollWheelZoom(true);
// 左上角，添加比例尺        
        var top_left_control = new BMap.ScaleControl({
            anchor : BMAP_ANCHOR_TOP_LEFT
        });
//左上角，添加默认缩放平移控件
        map.addControl(top_left_control);
        var top_left_navigation = new BMap.NavigationControl(); 
        map.addControl(top_left_navigation);
//清除地图上所有覆盖物
        map.clearOverlays();

        
// 百度地图API功能
    function theLocation(){
        var city = $("#city").find("option:selected").text();
        var dist = $("#dist").find("option:selected").text();
        var com = $('#com').val();
        var address = $('#address').val();
        console.log(city+dist+com+address);
        if(city != ""){
            map.centerAndZoom(city+dist,11);      // 用城市名设置地图中心点
        }
    }
    function theLocationCom(){
        $("#address").val('');
        var city = $("#city").find("option:selected").text();
        var com = $('#com').val();
        if(com != ""){
            var local = new BMap.LocalSearch(map, {
                pageCapacity: 1,
            });
            local.setSearchCompleteCallback(function (searchResult) {
        　　　　try{
                var poi = searchResult.getPoi(0);
                    lng =poi.point.lng;
                    lat =poi.point.lat;
                    console.log(lng,lat);
                    $('#lng').val(lng);
                    $('#lat').val(lat);
                    console.log(poi);
                map.clearOverlays();
                map.centerAndZoom(poi.point, 18);
                
                var marker = new BMap.Marker(poi.point);
        　　　　    map.addOverlay(marker);　    
        　　　　    marker.enableDragging();
        　　　　    marker.addEventListener("dragend", function(e){
                    lng =e.point.lng;
                    lat =e.point.lat;
                    $('#lng').val(lng);
                    $('#lat').val(lat);
                    console.log(lng,lat);
                    console.log(e);
              }); 
                $("#address").val(poi.address);
            }catch (ex) {
                
                }
        　　});
            local.search(com);     // 用小区名设置地图中心点
        }
    }
    
//地图结束

    $(function () {
        var prov = "{$member['prov']}";
       $.ajax({
            type:'post',
            url:"{:U('Member/getAreaInfo')}",
            async:false,
            data:'prov',
            dateType:'json',
            success:function(data){
                var data = eval('('+data+')');
                var str = '<option value="" selected >-请选择-</option>';
                if(data.status == 1){
                    for (var i in data.data){   
                        if(prov == data.data[i]['id']){

                            str=str+'<option selected="selected" value="'+data.data[i]['id']+'">'+data.data[i]['name']+'</option>';
                        }else{
                            str=str+'<option value="'+data.data[i]['id']+'">'+data.data[i]['name']+'</option>';
                        }
                    }
                    $("#prov").html(str);
                    $("#dist").html('<option value="" selected >-请选择-</option>');
                }
            }
            
        });
    })
 $(function(){
     getCity('prov','city')
     getCity('city','dist');
     theLocationCom();
 })

    /* 提交  确认添加 */
     /* $("#addList").click(function() {  */
         function addList(){ 
            var a = $("#prov").find("option:selected").text();
            var a1 = $("#prov").val();
            var b = $("#city").find("option:selected").text();
            var b1 = $("#city").val();
            var c = $("#dist").find("option:selected").text();
            var c1 = $("#dist").val();
            var d = $('#com').val();
            var e = $('#address').val();
            var addr = {'prov':a1,'city':b1,'dist':c1,'com':d,'address':e,lng:lng,lat:lat};
            //console.log(addr);
            $.ajax({
                type:"post",
                url:"{:U('add1')}",
                async:false,
                data:addr,
                dataType:"json",
                success:function (data) {                   
                    if (data.status == 1) {
                        alert("添加成功");
                        $("#com").val('');
                        $("#address").val('');
                        //location.reload();
                    } else if(data.status ==0){
                        alert(data.info);
                    } else{
                        alert("参数错误");
                    }
                }
            });
        }
    function getCity(pre,next){
        var pre= $('#'+pre).val();
        var prov = "{$member['prov']}";
        var city = "{$member['city']}";
        var dist = "{$member['dist']}";
        $("#"+next).show();
        $("#dist").html('<option value="" selected ></option>');
        $.ajax({
            type:'post',
            url:"{:U('Member/getAreaInfo')}",
            async:false,
            data:{'pid':pre},
            dateType:'json',
            success:function(data){
                var data = eval('('+data+')');
                var str = '<option value="" selected >-请选择-</option>';
                if(data.status == 1){
                    for (var i in data.data){ 
                        if(prov == data.data[i]['id'] || city == data.data[i]['id'] || dist == data.data[i]['id']){

                            str=str+'<option selected="selected" value="'+data.data[i]['id']+'">'+data.data[i]['name']+'</option>';
                        }else{
                            str=str+'<option value="'+data.data[i]['id']+'">'+data.data[i]['name']+'</option>';
                        }
                    }
                    $("#"+next).html(str);
                    
                }else{
                    $("#"+next).hide();
                    theLocation();
                }
            }
            
        });
    }
    
</script>
</body>
</html>
